<template>
  <form class="aj-widget-baidu-search" method="GET" action="http://www.baidu.com/baidu" onsubmit="//return g(this);">
    <input type="text" name="word" placeholder="请输入搜索之关键字" />
    <input name="tn" value="bds" type="hidden" />
    <input name="cl" value="3" type="hidden" />
    <input name="ct" value="2097152" type="hidden" />
    <input name="si" :value="getSiteDomainName" type="hidden" />
    <div class="searchBtn" onclick="this.parentNode.submit();"></div>
  </form>
</template>

<script lang="ts">
/**
 * Baidu 自定义搜索
 */
export default {
  props: {
    siteDomainName: String,
  },
  computed: {
    getSiteDomainName(): string {
      return this.siteDomainName || location.host || document.domain;
    },
  },
};
</script>

<style lang="less" scoped>
.aj-widget-baidu-search {
  padding: 0;
  margin: 0;

  input[type="text"] {
    border-radius: 5px;
    border: 1px solid gray;
    padding: 0 2px;
    height: 22px;
  }

  .searchBtn {
    background: url("")
      no-repeat center;
    width: 25px;
    height: 25px;
    cursor: pointer;
    display: inline-block;
    vertical-align: bottom;
  }
}
</style>